<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link href="__PUBLIC__/js/auto/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="__PUBLIC__/js/auto/jquery.autocomplete.js"></script>
        <script type="text/javascript">
            function sharebtnn(question_id,share_id,url){
                $.get(url, {question_id: question_id, share_id: share_id },function(data){
                    if(data == 1){
                        alert('分享成功！');
                    }
                    else if(data == 2){
                        alert('请不要重复分享');
                    }
                    else{
                        alert('服务器忙，请重试！');
                    }
                }
            );

            }

            function autoContent(url,obj){
                if($("#"+obj).val() == '请选择或新建'){
                    $("#"+obj).val('');
                }
                bValue = null;
                cValue = null;
                if(obj=='category_input'){
                    bValue = $("#brand_input").val();
                }
                else if(obj=='commodity_input'){
                    cValue = $("#category_input").val();
                    bValue = $("#brand_input").val();
                }
                $("#"+obj).autocomplete(url, {
                    width: 230,
                    max:10,
                    dataType: "json",
                    autoFill :false,
                    minChars:0,
                    selectFirst:false,
                    extraParams: {b:bValue,c:cValue},
                    scrollHeight: 300,
                    parse: function(data) {
                        //alert(data);
                        if(data.length >=1){
                            return $.map(eval(data), function(row) {
                                res = row.split('-');
                                return {
                                    data: row,
                                    value: res[1] ,
                                    result: res[1]
                                }
                            });
                        }
                    },
                    formatItem: function(item) {
                        if(item.length > 1){
                            item = item.split('-');
                            return "<table width='90%'><tr><td align = \"left\">" + item[0] +"</td>"+"<td align = \"right\">"+ item[1]+"</td></tr></table>";
                        }
                    }
                });
            }
            function searchMyShare(){
                var question_id  = $("#question_id").val();
                var searchBrand  = $("#brand_input").val();
                var searchCategory = $("#category_input").val();
                var searchCommodity = $("#commodity_input").val();

      //          var searchBrand  = encodeURI(searchBrand);
              //  var searchCategory = encodeURI(searchCategory);
             //   var searchCommodity = encodeURI(searchCommodity);
                
                var sortTime =  $("#sortTime").val();
                var url = "__APP__/Home/Share/searchMemberShareAjax";
                
                $.post(
                url,
                {question_id: question_id, brand_word: searchBrand,category_word:searchCategory,commodity_word:searchCommodity,sort:sortTime},
                function(data){
                    $("#shareMessage").html(data);
                });
            }
            function searchMyShareByPage(p){
                var question_id  = $("#question_id").val();
                var searchBrand  = $("#brand_input").val();
                var searchCategory = $("#category_input").val();
                var searchCommodity = $("#commodity_input").val();
            //    var searchBrand  = encodeURI(searchBrand);
            //    var searchCategory = encodeURI(searchCategory);
             //   var searchCommodity = encodeURI(searchCommodity);

                var sortTime =  $("#sortTime").val();
                var url = "__APP__/Home/Share/searchMemberShareAjax";
                $.post(
                url,
                {question_id: question_id, brand_word: searchBrand,category_word:searchCategory,commodity_word:searchCommodity,sort:sortTime,p:p},
                function(data){
                    $("#shareMessage").html(data);
                });
            }
        </script>
    </head>
    <body>
    <input type="hidden" value="{$id}" id="question_id"/>




        <div class="panel_topleft" style="width:890px;">
            <div class="panel_topright">
                <div class="panel_topmiddle">
                    <div class="search1" id="Search" >
                        <div class="search_item" id="searchBrand">
                            <input value="品牌：" size="4" disabled="true"><input type="text" size="13" id="brand_input" value="" onclick="autoContent('__APP__/Home/Share/autoBrand/','brand_input');">
                        </div>

                        <div class="search_item" id="searchCategory">
                            <input value="品类：" size="4" disabled="true"><input type="text" size="13" id="category_input" value="" onclick="autoContent('__APP__/Home/Share/autoCategory/','category_input');">
                        </div>

                        <div class="search_item" id="searchCommodity">
                            <input value="品名：" size="4" disabled="true"><input type="text" size="13" id="commodity_input" value="" onclick="autoContent('__APP__/Home/Share/autoCommodity/','commodity_input');">
                        </div>

                        <a href="javascript:;" class="searchbtn" id="searchShare" onclick="searchMyShare();">搜索</a>
                        <select id="sortTime" onchange="searchMyShare();">
                            <option value="asc">按时间正序</option>
                            <option value="desc">按时间倒序</option>
                        </select>
                    </div>
                    <div class="panelcolse" id="closeSharemessage" title="关闭"></div>
                </div>
            </div>
        </div>

        <div class="panel_mainleft" style="height:800px;width:890px;">
            <div class="panel_mainright">
                <div class="panel_mainmiddle" id="shareMessage">
                    <input type="hidden" id="question_id" value="{$id}">
                    <volist name="list" id="share">
                        <div class="sharemessage">
                            <div class="subject">
                                <span class="title">{$share.caption|html_entity_decode=###}</span>
                                <span class="date">发布时间：{$share.time_add|date="Y-m-d",###}</span>
                            </div>
                            <div class="message">
				{$share.content|html_entity_decode=###|strip_tags=###}
                                <span class="veiw_all"><a href="__APP__/Share/show/id/{$share.id}" target="_blank">[查看全文...]</a></span>
                            </div>
                            <div class="sharem">
                                <a href="javascript:;" onclick="sharebtnn('{$id}','{$share.id}','__APP__/Home/Question/addShare');">分享</a>

                            </div>
                        </div>
                    </volist>

                    <div id="mysharePage" class="paging">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
        <div class="panel_bottomleft" style="width:890px;">
            <div class="panel_bottomright">
                <div class="panel_bottommiddle">
                </div>
            </div>
        </div>

    </body>
</html>